﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ZhiAo.CommonLibrary
{
    public class LogHelper
    {
        public static void DebuggerWrite(string message)
        {
            try
            {
                string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"\RUNTIME_DEBUGGER";
                if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                string filename = path + @"\DEBUGGER" + DateTime.Now.ToString("yyyyMMddHH") + ".txt";
                StreamWriter sw = File.AppendText(filename);
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                sw.WriteLine(time + " " + message);
                sw.Close();
            }
            catch
            {
            }
        }


        public static void Write(string message, string fileName)
        {
            try
            {
                string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"\LOG";
                if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                string filename = path + "\\" + fileName + "_" + DateTime.Now.ToString("yyyyMMddHH") + ".txt";
                StreamWriter sw = File.AppendText(filename);
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                sw.WriteLine(time + " " + message);
                sw.Close();
            }
            catch
            {
            }
        }
    }
}
